{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>智能WMS库存分析系统 | AI-Powered Logistics Analytics</title>
    <!-- Bootstrap 5 -->
    <link href="{% static 'plugins/bootstrap-5.3.0-alpha1-dist/css/bootstrap.min.css' %}" rel="stylesheet">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{% static 'plugins/fontawesome-free-6.7.2-web/css/all.min.css' %}">

    <style>
        :root {
            --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 30%, #3b82f6 100%);
            --glass-bg: rgba(255, 255, 255, 0.98);
            --shadow-primary: 0 25px 50px -12px rgba(99, 102, 241, 0.15);
        }

        body {
            background: linear-gradient(45deg, #f8fafc 0%, #eef2ff 100%);
            min-height: 100vh;
            font-family: 'Inter', 'Helvetica Neue', Arial, 'PingFang SC', sans-serif;
            display: flex;
            align-items: center;
        }

        .main-card {
            border: none;
            border-radius: 2rem;
            box-shadow: var(--shadow-primary);
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            transform: translateY(0);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .main-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 30px 60px -10px rgba(99, 102, 241, 0.2);
        }

        .card-header {
            background: var(--primary-gradient);
            padding: 3rem 2rem;
            position: relative;
            overflow: hidden;
            border-radius: 2rem 2rem 0 0 !important;
        }

        .card-header::after {
            content: '';
            position: absolute;
            bottom: -30px;
            left: 0;
            width: 100%;
            height: 60px;
            background: linear-gradient(to bottom, rgba(255,255,255,0.2) 0%, transparent 100%);
        }

        .header-content {
            position: relative;
            z-index: 2;
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .upload-container {
            border: 2px dashed rgba(99, 102, 241, 0.2);
            border-radius: 1.5rem;
            background: rgba(245, 243, 255, 0.3);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
        }

        .upload-container:hover {
            border-color: #6366f1;
            background: rgba(99, 102, 241, 0.05);
        }

        .upload-container.dragover {
            transform: scale(1.02);
            box-shadow: 0 10px 20px rgba(99, 102, 241, 0.1);
        }

        .upload-icon {
            font-size: 4rem;
            background: var(--primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            filter: drop-shadow(0 4px 6px rgba(99, 102, 241, 0.1));
            transition: transform 0.3s ease;
        }

        .btn-analytics {
            background: var(--primary-gradient);
            border: none;
            padding: 1.2rem 3rem;
            border-radius: 1.2rem;
            position: relative;
            overflow: hidden;
            transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }

        .btn-analytics::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(
                120deg,
                transparent,
                rgba(255, 255, 255, 0.3),
                transparent
            );
            transition: left 0.8s;
        }

        .btn-analytics:hover {
            transform: translateY(-3px);
            box-shadow: 0 15px 30px rgba(99, 102, 241, 0.3);
        }

        .btn-analytics:hover::before {
            left: 100%;
        }

        .file-info {
            background: rgba(99, 102, 241, 0.05);
            border-radius: 1rem;
            padding: 1rem;
            border: 1px solid rgba(99, 102, 241, 0.1);
            transition: all 0.3s ease;
        }

        .file-info:hover {
            transform: translateX(5px);
        }

        @keyframes floating {
            0% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0); }
        }

        .floating-icon {
            animation: floating 3s ease-in-out infinite;
        }

        @media (max-width: 768px) {
            .main-card {
                margin: 1.5rem;
                border-radius: 1.5rem;
            }

            .card-header {
                padding: 2rem 1.5rem;
            }

            .upload-icon {
                font-size: 3rem;
            }

            .btn-analytics {
                width: 100%;
                padding: 1rem 2rem;
            }
        }
    </style>
</head>
<body>
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="main-card">
                <!-- 动态卡片头部 -->
                <div class="card-header text-white text-center">
                    <div class="header-content">
                        <h1 class="mb-4 display-5 fw-bold">
                            <i class="fas fa-rocket me-3 floating-icon"></i>智能WMS库存分析
                        </h1>
                        <p class="lead mb-0 opacity-90">AI驱动的物流数据洞察平台</p>
                    </div>
                </div>

                <!-- 卡片主体 -->
                <div class="card-body p-4 p-lg-5">
                    <form method="post" enctype="multipart/form-data" id="uploadForm">
                        {% csrf_token %}

                        <!-- 拖拽上传区域 -->
                        <div class="mb-4">
                            <div class="upload-container" id="dropZone">
                                <div class="py-5 text-center position-relative">
                                    <div class="mb-4">
                                        <i class="fas fa-file-import upload-icon"></i>
                                    </div>
                                    <input
                                        type="file"
                                        class="form-control visually-hidden"
                                        name="file"
                                        id="fileInput"
                                        required
                                        onchange="updateFileName()"
                                    >
                                    <label for="fileInput" class="btn btn-lg btn-light px-4 mb-3">
                                        <i class="fas fa-folder-open me-2"></i>选择数据文件
                                    </label>
                                    <div class="file-info" id="fileName">
                                        <i class="fas fa-info-circle me-2 text-primary"></i>
                                        <span class="text-muted">支持 .xlsx, .xls 格式</span>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 动态提交按钮 -->
                        <div class="d-grid mt-4">
                            <button type="submit" class="btn btn-analytics text-white">
                                <i class="fas fa-magic me-2"></i>立即智能解析
                            </button>
                        </div>
                    </form>

                    <!-- 错误提示 -->
                    {% if error %}
                    <div class="alert alert-danger mt-4 d-flex align-items-center animate__animated animate__shakeX">
                        <i class="fas fa-exclamation-triangle fs-5 me-3"></i>
                        <div class="flex-grow-1">{{ error }}</div>
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    // 增强交互体验
    const dropZone = document.getElementById('dropZone');
    const fileInput = document.getElementById('fileInput');

    // 拖拽交互
    dropZone.addEventListener('dragover', (e) => {
        e.preventDefault();
        dropZone.classList.add('dragover');
    });

    ['dragleave', 'drop'].forEach(event => {
        dropZone.addEventListener(event, () => {
            dropZone.classList.remove('dragover');
        });
    });

    dropZone.addEventListener('drop', (e) => {
        e.preventDefault();
        fileInput.files = e.dataTransfer.files;
        updateFileName();
    });

    // 文件选择处理
    function updateFileName() {
        const file = fileInput.files[0];
        const fileNameDiv = document.getElementById('fileName');

        if (file) {
            const fileType = file.name.split('.').pop().toLowerCase();
            const iconClass = fileType === 'csv' ? 'fa-file-csv' : 'fa-file-excel';

            fileNameDiv.innerHTML = `
                <i class="fas ${iconClass} me-2 text-success"></i>
                <span class="fw-medium">${file.name}</span>
                <span class="text-muted ms-2">(${(file.size/1024/1024).toFixed(2)} MB)</span>
            `;
            fileNameDiv.classList.add('file-info--active');
        } else {
            fileNameDiv.innerHTML = `
                <i class="fas fa-info-circle me-2 text-primary"></i>
                <span class="text-muted">支持 .xlsx, .xls 格式</span>
            `;
            fileNameDiv.classList.remove('file-info--active');
        }
    }

    // 表单提交动画
    document.getElementById('uploadForm').addEventListener('submit', function(e) {
        const btn = this.querySelector('button[type="submit"]');
        btn.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>分析中...';
        btn.disabled = true;
    });
</script>

<!-- Bootstrap 5 JS -->
<script src="{% static 'plugins/bootstrap-5.3.0-alpha1-dist/js/bootstrap.bundle.min.js' %}"></script>
</body>
</html>